<template>
	<view class="setting">
		<view class="ucenter">
			<view class="menu-lists">
				<view class="item" @click="viewSharePost()">
					<view class="icon">
						<view class="iconfont icon-wodeyaoqingma"></view>
					</view>
					<view class="name muti">
						<view class="main-name">邀请码及海报</view>
						<view class="sub-name">
							<view class="text">{{inviteCode}}</view>
							<view class="icon">
								<view class="iconfont icon-jiantou"></view>
							</view>
						</view>
					</view>
				</view>
				<view class="item" @click="analysis()">
					<view class="icon">
						<view class="iconfont icon-iconfonticon-xitong"></view>
					</view>
					<view class="name muti">
						<view class="main-name">我的邀请</view>
						<view class="sub-name">
							<view class="icon">
								<view class="iconfont icon-jiantou"></view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import api from "@/utils/api/invite/index.js"
	export default {
		data() {
			return {
				inviteCode: "",
				sharePostImage: "",
			}
		},
		onLoad() {
			this.sharePost();
		},
		methods: {
			async sharePost() {
				let res = await api.sharePost();
				if (res.status == 1) {
					this.inviteCode = res.data.invite_code;
					this.sharePostImage = res.data.img_source;
				}
			},
			viewSharePost() {
				uni.navigateTo({
					url: "share-app?image=" + this.sharePostImage + "&code=" + this.inviteCode
				})
			},
			analysis() {
				uni.navigateTo({
					url: "index"
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #18142F;
	}

	view {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
	}
</style>
